package org.zxl.springbootdemo.security.repository;

import org.apache.catalina.User;
import org.springframework.stereotype.Service;
import org.zxl.springbootdemo.security.entity.UserInfo;

import javax.annotation.Resource;
import java.lang.reflect.Array;
import java.util.*;
import java.util.stream.Collectors;

//public interface UserInfoRepository extends JpaRepository<UserInfo, Long> {
//    public UserInfo findByUsername(String username);
//}
@Service
public class UserInfoRepository {
    public UserInfo findByUsername(String username) {
        return userInfos.get(username);
    }

    private Map<String , UserInfo> userInfos = new HashMap<>();

    public void save(UserInfo userInfo){
        userInfos.put(userInfo.getUsername(), userInfo);
    }

    public List<UserInfo> findAll(){
        return userInfos.entrySet().stream().map(s -> s.getValue()).collect(Collectors.toList());
    }
}